package com.xm.xmapp.dialog;

import android.annotation.SuppressLint;
import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.util.DisplayMetrics;
import android.view.LayoutInflater;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.TextView;

import com.xm.xmapp.R;

public class ShortTimeTipDialog extends Dialog {

	private Context context;

	private TextView text1, text2, text3, tip;
	private String str1, str2;
	private float str3,str4;
	

	public ShortTimeTipDialog(Context context, String str1, String str2, float str3, float str4) {
		super(context, R.style.FenShiDialog);
		// TODO Auto-generated constructor stub
		this.context = context;
		this.str1 = str1;
		this.str2 = str2;
		this.str3 = str3;
		this.str4 = str4;
	}

	@SuppressLint("InflateParams")
	public void init() {
		LayoutInflater inflater = LayoutInflater.from(context);
		View view = inflater.inflate(R.layout.dialog_shorttime_tip, null);
		view.findViewById(R.id.dissmiss).setOnClickListener(
				new View.OnClickListener() {

					@Override
					public void onClick(View v) {
						dismiss();

					}
				});

		text1 = (TextView) view.findViewById(R.id.text1);
		text1.setText(str1);
		text2 = (TextView) view.findViewById(R.id.text2);
		text2.setText(str2);

		text3 = (TextView) view.findViewById(R.id.text3);
		tip = (TextView) view.findViewById(R.id.tip);
		if (str3 > 0)
			text3.setText("用车起步价：" + str3+"元");
		else
			text3.setText("用车起步价：免起步价");
		
		
		if (str4 > 0)
			tip.setText("注：一天24小时内最高限额收费" + str4+"元，次日重新计费");
		else
			tip.setText("最高限额收费");
		
//		注:一天24小时内最高限额收费99元，次日重新计费

		setContentView(view);

		Window dialogWindow = getWindow();
		WindowManager.LayoutParams lp = dialogWindow.getAttributes();
		DisplayMetrics d = context.getResources().getDisplayMetrics(); // 获取屏幕宽、高用
		lp.width = (int) d.widthPixels; // 高度设置为屏幕的0.6
		lp.height = (int) d.heightPixels;
		dialogWindow.setAttributes(lp);
	}

	@Override
	public void show() {
		// TODO Auto-generated method stub
		super.show();
		/** 3.自动弹出软键盘 **/

	}

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		init();

	}
}
